efform_onload = function ()
{
};  

button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_result", "ZM", "ZMCG60", "query");
}

button_update_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行修改！"); return;
		}
	}
	efgrid.submitForm("ef_grid_result", "ZM", "ZMCG60", "update", true);
}

button_insert_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return;	
	efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG60", "insert", true);
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行删除！"); return;
		}
	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG60", "delete", true);
	}); 
}

button_report_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行生效！"); return;
		}
	}
	EFConfirm('确认要生效吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG60", "report", true);
	});
}

efgrid_afterAddNewRow = function(grid_id) {
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if (grid_id == "ef_grid_result") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdStatus", "草拟");
			grid.getBlockData().setCell(rows[i], "fdCreateDate", getCurrentDate());
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
		}
	}
}

button_upload_onclick=function(){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return;
	var row_index=grid.getCheckedRowCount();
	var row=grid.getCheckedRows();
	if(row_index>1){
		EFAlert("只能选中一条项目信息后上传！");
		return;
	}
	var docId=grid.getCellValueByColumnName(row,"fdDocId");
	if(!isAvailable(docId)) {
		EFAlert("未指定文档号！", "系统警告");
		return false;
	}
	var url = "DispatchAction.do?efFormEname=EUAF3501";
		url = url + "&inqu_status-0-code=zm.cp";
	
	if(grid.getCellValueByColumnName(row,"fdStatus")!="草拟")
	{
		url = url + "&editFlag=0";
	}else{
		url = url + "&editFlag=1";
	}
	url = url + "&inqu_status-0-docId="+docId+"&time=" + new Date().getTime();
	
	EFColorbox({href:url,title:"附件管理",width:"80%", height:"80%", iframe:true});
}

